package com.ruoyi.life.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.life.domain.FeApartmentCancel;
import com.ruoyi.life.service.IFeApartmentCancelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 公寓退租记录Controller
 *
 * @author cjie
 * @date 2022-09-20
 */
@Api(tags = " 公寓退租记录")
@RestController
@RequestMapping("/feApartmentCancel")
public class FeApartmentCancelController extends BaseController {
    @Autowired
    private IFeApartmentCancelService feApartmentCancelService;

    /**
     * 查询公寓退租记录列表
     */
    @ApiOperation(value="查询公寓退租记录列表", notes="查询公寓退租记录列表")
    @PreAuthorize(hasPermi = "life:feApartmentCancel:list")
    @GetMapping("/list")
    public TableDataInfo list(FeApartmentCancel feApartmentCancel) {
        startPage();
        List<FeApartmentCancel> list = feApartmentCancelService.selectFeApartmentCancelList(feApartmentCancel);
        return getDataTable(list);
    }

    /**
     * 导出公寓退租记录列表
     */
    @ApiOperation(value="导出公寓退租记录列表", notes="导出公寓退租记录列表")
    @PreAuthorize(hasPermi = "life:feApartmentCancel:export")
    @Log(title = "公寓退租记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FeApartmentCancel feApartmentCancel) throws IOException {
        List<FeApartmentCancel> list = feApartmentCancelService.selectFeApartmentCancelList(feApartmentCancel);
        ExcelUtil<FeApartmentCancel> util = new ExcelUtil<FeApartmentCancel>(FeApartmentCancel.class);
        util.exportExcel(response, list, "公寓退租记录数据");
    }
    /**
     * 获取公寓退租记录详细信息
     */
    @ApiOperation(value="获取公寓退租记录详细信息", notes="获取公寓退租记录详细信息")
    @PreAuthorize(hasPermi = "life:feApartmentCancel:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(feApartmentCancelService.selectFeApartmentCancelById(id));
    }

    /**
     * 获取公寓退租记录详细信息
     */
    @ApiOperation(value="WX-获取公寓退租记录详细", notes="WX-获取公寓退租记录详细")
    @GetMapping(value = "/getVO/{id}")
    public AjaxResult getVOInfo(@PathVariable("id") String id) {
        return AjaxResult.success(feApartmentCancelService.selectFeApartmentCancelVOById(id));
    }

    /**
     * 根据企业id,查询租赁合同详情。
     */
    @ApiOperation(value="WX-获取公寓租赁分组", notes="WX-获取公寓租赁分组")
    @GetMapping(value = "/getGroupVO/{id}")
    public AjaxResult getLeaseDetailVOList(@PathVariable("id") String enteripseId) {
        return AjaxResult.success(feApartmentCancelService.selectLeaseDetailGroupVOById(enteripseId));
    }

    /**
     * 新增公寓退租记录
     */
    @ApiOperation(value="新增公寓退租记录", notes="新增公寓退租记录")
    @PreAuthorize(hasPermi = "life:feApartmentCancel:add")
    @Log(title = "公寓退租记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeApartmentCancel feApartmentCancel) {
        return toAjax(feApartmentCancelService.insertFeApartmentCancel(feApartmentCancel));
    }

    /**
     * 修改公寓退租记录
     */
    @ApiOperation(value="修改公寓退租记录", notes="修改公寓退租记录")
    @PreAuthorize(hasPermi = "life:feApartmentCancel:edit")
    @Log(title = "公寓退租记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeApartmentCancel feApartmentCancel) {
        return toAjax(feApartmentCancelService.updateFeApartmentCancel(feApartmentCancel));
    }

    /**
     * 删除公寓退租记录
     */
    @ApiOperation(value="删除公寓退租记录", notes="删除公寓退租记录")
    @ApiImplicitParam(name = "ids", value = "公寓退租记录ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "life:feApartmentCancel:remove")
    @Log(title = "公寓退租记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(feApartmentCancelService.deleteFeApartmentCancelByIds(ids));
    }
}
